package com.yao.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yao.mall.mapper.ShoppingOrderMapper;
import com.yao.mall.model.entity.ShoppingOrderDetail;
import com.yao.mall.model.vo.ShoppingOrderDetailVO;
import com.yao.mall.service.ShoppingOrderDetailService;
import com.yao.mall.mapper.ShoppingOrderDetailMapper;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author jiahua.yao
* @description 针对表【shopping_order_detail】的数据库操作Service实现
* @date 2024-03-26 19:31:18
*/
@Service
public class ShoppingOrderDetailServiceImpl extends ServiceImpl<ShoppingOrderDetailMapper, ShoppingOrderDetail>
    implements ShoppingOrderDetailService{

    @Resource
    private ShoppingOrderDetailMapper shoppingOrderDetailMapper;

   @Override
   public List<ShoppingOrderDetailVO> getShoppingOrderDetailVOS(Long id) {
        QueryWrapper<ShoppingOrderDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id", id);
        List<ShoppingOrderDetail> shoppingOrderDetails = shoppingOrderDetailMapper.selectList(queryWrapper);
        List<ShoppingOrderDetailVO> orderDetailVOS = shoppingOrderDetails.stream().map(shoppingOrderDetail -> {
            ShoppingOrderDetailVO shoppingOrderDetailVO = new ShoppingOrderDetailVO();
            BeanUtils.copyProperties(shoppingOrderDetail, shoppingOrderDetailVO);
            return shoppingOrderDetailVO;
        }).toList();
        return orderDetailVOS;
    }

}




